#ifndef CONSOLE_H
#define CONSOLE_H

#include <QWidget>
#include <QString>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QDebug>
#include <QFile>
#include <QTextStream>
#include "QThread"

#include <QRegExp>
#include "script_thread.h"
#include "console_thread.h"
#include "com.h"

namespace Ui {
class console;
}

class console : public QWidget
{
    Q_OBJECT

public:
    explicit console(QWidget *parent = 0, Script_thread *scritp = 0);
    ~console();

    void start_test(bool flag, QString portname, int baundrate);
	void *add_check_rule(QString rule);
	void delete_rule(void *rule);

	Console_thread *thread;



private:
    Ui::console *ui;
	Script_thread *script;
    void Read_Data(void);
	Com *com;
	QThread *td;

    QSerialPort  *port;
    //QString       receive_data;
    QByteArray      receive_data;

    bool          start_flag;
    int           result_line;
    bool          read_data_running;
	QString			log_filename;

    QRegExp       *colorPrint;

    void set_consolecolor(int d);
	void check_line(QString line);

	QList<QRegExp*> checklist;

signals:

private slots:
    void on_textEdit_2_textChanged();

public slots:
	void printToText(QString str);

};

#endif // CONSOLE_H
